import React, { useState, useRef } from 'react';
import { Button } from 'antd';
import ProTable from '@ant-design/pro-table';
import { user } from './service';

const UserTable = () => {
  const actionRef = useRef();
  const [currentRow, setCurrentRow] = useState();

  const columns = [
    {
      title: '用户名',
      dataIndex: 'userName',
      tip: '这是用户名',
    },
    {
      title: '邮箱',
      dataIndex: 'email',
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <Button
          size="small"
          key="primary"
          onClick={() => {
            setCurrentRow(record);
          }}
          danger
        >
          删除
        </Button>,
      ],
    },
  ];
  return (
    <ProTable
      rowKey="key"
      actionRef={actionRef}
      search={false}
      columns={columns}
      request={user}
      options={false}
      toolBarRender={() => [
        <Button type="primary" key="primary">
          刷新
        </Button>,
      ]}
    ></ProTable>
  );
};

export default UserTable;
